﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FavoritesModel = A911CareerKit.Favorites.Model;
using System.IO;

namespace A911CareerKit
{
    internal static class Locator
    {
        public static void InitLocator()
        {
            try
            {
                Favorites = FavoritesModel.Favorites.Load();
            }
            catch (FileNotFoundException) // If file not found - need to create new enviroumnent
            {
                Favorites = FavoritesModel.Favorites.New();
            }            
        }

        #region Favorites
        
        public static FavoritesModel.Favorites Favorites { get; private set; }

        public static event LocatorService.FavoritesSubscriberHandle OnFavoritesChanged;

        /// <summary>
        /// Call this method when favorites changed
        /// </summary>
        /// <param name="sender"></param>
        public static void FavoritesChanged(object sender)
        {
            Favorites.Save();
            OnFavoritesChanged(sender, new EventArgs());
        }

        #endregion
    }
}
